import json

import jmespath
from deepdiff import DeepDiff
from loguru import logger


def jmespath_withdraw(data, expression=""):
    return jmespath.search(f"data.list{expression}", data)


def check_key_integrity(obj, response):
    res = DeepDiff(obj, response)
    if 'dictionary_item_added' in res:
        logger.info(f"新增字段: {res['dictionary_item_added']}")
        return False
    elif 'dictionary_item_removed' in res:
        logger.info(f"删除字段: {res['dictionary_item_removed']}")
        return False
    else:
        return True



